package com.kaiyiweitong.tongxing.activity.my.setting;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;

import com.kaiyiweitong.tongxing.R;
import com.kaiyiweitong.tongxing.base.BaseActivity;
import com.kaiyiweitong.tongxing.util.CommonUtil;
import com.kaiyiweitong.tongxing.util.MyTextUtils;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/12/19 0019.
 */

public class SetPayPswActivity extends BaseActivity implements TextWatcher {
    @Bind(R.id.pay_psw)
    EditText mPayPsw;
    @Bind(R.id.clear)
    ImageView mClear;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_set_pay_psw);
        ButterKnife.bind(this);
        init();
    }

    private void init() {
        mPayPsw.addTextChangedListener(this);
    }

    @OnClick({R.id.clear, R.id.finish})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.clear:
                mPayPsw.setText("");
                break;
            case R.id.finish:
                if (MyTextUtils.checkTextContent(mPayPsw).equals("")) {
                    CommonUtil.toast(this,R.string.psw_not_blank);
                }else {

                }
                break;
        }
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {

    }

    @Override
    public void afterTextChanged(Editable s) {
        if (MyTextUtils.checkTextContent(mPayPsw).equals("")) {
            mClear.setVisibility(View.INVISIBLE);
        } else {
            mClear.setVisibility(View.VISIBLE);
        }
    }
}
